home *** CD-ROM | disk | FTP | other *** search
/ IRIX 6.4 Applications 1997 August / SGI IRIX 6.4 Applications 1997 August.iso / dist / dynaweb.idb / usr / lib / Insight / data / config / procdef.dwc.z / procdef.dwc
Encoding:
Text File  |  1997-07-30  |  3.7 KB  |  125 lines

  1. ##=====================================================================    
  2. ## Sense client capabilities
  3. ##=====================================================================    
  4.  
  5. proc dwSenseClientCapabilities {} {
  6.  
  7.   ## NOTE: can't get user-agent field in CGI mode
  8.   set UserAgent [dwGetHttpField "user-agent"]
  9.  
  10.   set Display        "TTY"
  11.   set PlatForm       "unknown"
  12.   set Frames         "0"
  13.   set Agent          "unknown"
  14.   set MajorVer       "unknown"
  15.   set MinorVer       "unknown"
  16.   set Tables         "1"
  17.   set Entities       "1"
  18.   set RelativeURLs   "1"
  19.   # Pretty much assured to be true....
  20.   set BrokenCharset  "1" 
  21.   
  22.   # Ladder for detecting platform
  23.   if {[string match "*SunOS*" $UserAgent] == 1} {
  24.      set PlatForm "unix"
  25.   }
  26.   
  27.   # Ladder to detect the display type
  28.   #     - X11 Clients are assumes to be Unix based
  29.   if {[string match "*X11*" $UserAgent] == 1} {
  30.      set PlatForm "unix"
  31.      set Display  "X11"
  32.   }
  33.   if {[string match "*X Window System*" $UserAgent] == 1} {
  34.      set PlatForm "unix"
  35.      set Display  "X11"
  36.   }
  37.   
  38.   # Break up the user-agent field
  39.   set vpos     [string first "/" $UserAgent]  
  40.   set Agent    [string trim [string range $UserAgent 0 [expr $vpos - 1]]]
  41.   set version  [string range $UserAgent [incr vpos] end]
  42.   set version  [string range $version 0 [string first " " $version]]
  43.   set vpos     [string first "." $version]
  44.   set MajorVer [string trim [string range $version 0 [expr $vpos - 1]]]
  45.   set MinorVer [string trim [string range $version  [incr vpos] end]]
  46.   set MinorVer [string trim [string range $MinorVer 0 1]]
  47.   
  48.   # Check for frames support
  49.   if {[string match "Mozilla*" $Agent] == 1} {
  50.      if {$MajorVer >= 2} {
  51.     set Frames 1
  52.      }
  53.      if {$MajorVer < 2} {
  54.     set Tables   0
  55.     set Entities 0
  56.      } 
  57.   } elseif {[string match "Spyglass*" $Agent] == 1} {
  58.      if {$MajorVer == 2} {
  59.     if {$MinorVer >= 11} {
  60.        set Frames          0
  61.        set Tables          1
  62.        set Entities        1
  63.        set RelativeURLs    1
  64.     } 
  65.      }
  66.   } elseif {[string match "Multilingual Mosaic*" $Agent] == 1} {
  67.      set Frames          0
  68.      set Tables          1
  69.      set Entities        1
  70.      set RelativeURLs    1
  71.   } elseif {[string match "*Mosaic*" $Agent] == 1} {
  72.      if {$MajorVer == 2} {
  73.     if {$MinorVer < 7} {
  74.        set Frames          0
  75.        set Tables          0
  76.        set Entities        0
  77.        set RelativeURLs    0
  78.     } 
  79.      }
  80.   } elseif {[string match "*Lynx*" $Agent] == 1} {
  81.      set Frames          0
  82.      set Tables          0
  83.      set Entities        0
  84.      set RelativeURLs    0
  85.   } 
  86.  
  87.   # Build up the capabilities list
  88.   lappend capabilities [list "platform"       $PlatForm]
  89.   lappend capabilities [list "display"        $Display]
  90.   lappend capabilities [list "frames"         $Frames]
  91.   lappend capabilities [list "agent"          $Agent]
  92.   lappend capabilities [list "major"          $MajorVer]
  93.   lappend capabilities [list "minor"          $MinorVer]
  94.   lappend capabilities [list "tables"         $Tables]
  95.   lappend capabilities [list "entities"       $Entities]
  96.   lappend capabilities [list "relative-urls"  $RelativeURLs]
  97.   lappend capabilities [list "broken_charset" $BrokenCharset]
  98.  
  99.   return $capabilities
  100. }
  101.  
  102.  
  103. proc dwQueryCapability {name caplist} {
  104.   foreach item $caplist {
  105.      if {[lsearch $item $name] != -1} {
  106.     return [lindex $item 1]
  107.      }
  108.   }
  109.   return ""
  110. }
  111.  
  112.  
  113. ##======================================================================
  114. ## Map from the ECM name to the legal IANA value
  115. ##======================================================================
  116.  
  117. proc dwMapEcmToIANA {encoding} {
  118.    switch -exact -- $encoding {
  119.       "C"         { return "iso-8859-1" }
  120.       "ja_euc"    { return "euc-jp" }
  121.       "ja_sjis"   { return "shift-jis" }
  122.       "utf8"      { return "UNICODE-1-1-UTF-8"}
  123.    }
  124. }
  125.